package com.nuanshui.heatedloan.web.appsystem;

import com.alibaba.dubbo.config.annotation.Reference;
import com.google.common.collect.Maps;
import com.nuanshui.framework.res.ResourceFacade;
import com.nuanshui.heatedloan.baseservice.facade.PictureConfigService;
import com.nuanshui.heatedloan.baseservice.model.SystemPicture;
import com.nuanshui.heatedloan.constant.GlobalParam;
import com.nuanshui.heatedloan.pageable.Pager;
import com.nuanshui.heatedloan.util.dwz.Pager2DwzPageUtil;
import com.nuanshui.heatedloan.web.ApiController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/cms/manage/loadpicture")
public class LoadPictureController extends ApiController{


	@Reference(url = GlobalParam.BASESERVICE_DUBBO_SERVER, timeout = GlobalParam.DUBBO_SERVER_TIME_OUT,version = GlobalParam.BASESERVICE_DUBBO_SERVER_VERSION)
	private PictureConfigService pictureConfigService;
	
	@Autowired
	private ResourceFacade resourceFacade;

	@RequestMapping("/list")
	public String list(Pager<SystemPicture> pager){

		pager = pictureConfigService.listLoadPicture(pager);
		return success(pager.asHashMap());
	}
	
	@RequestMapping("/update")
	public String update(SystemPicture picture){
		pictureConfigService.updateSystemKey(picture);
		return success();
	}
	
	@RequestMapping(value="/create")
	public String create(SystemPicture picture){
		picture.setType(1);//启动图的类型为1
		pictureConfigService.save(picture);
		return success();
	}
	
	@RequestMapping(value="/delete")
	public String delete(String id){
		pictureConfigService.delete(id);
		return success();
	}
	
}
